home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
003
/
wildproc.arc
/
WILDPROC.PRG
< prev
Wrap
Text File
|
1986-11-19
|
4KB
|
100 lines
*****************************************************************************
* WILDPROC.PRG *
*****************************************************************************
* *
* W I L D *
* *
* This procedure is used to generate a macro to be used with a filter *
* or copy command to select records based on a wild card. *
* *
* AUTHOR: Laurens Meyer, Remarkable Enterprises, Dunedin New Zealand *
* *
* SOURCE ID: AAJ865 *
* *
* INPUTS: codematch This has the wildcard ie '???A0??' *
* field Name of the database field to match *
* *
* OUTPUTS: matchmac Macro used in SET FILTER etc ie *
* COPY TO temp FOR &matchmac *
* SET FILTER TO &matchmac *
* *
*****************************************************************************
PROCEDURE wild
PARAMETERS codematch, matchmac, field
PRIVATE cnt1, cnt2, work1, work2, work3, sstr, scnt, len
len = LEN(codematch)
matchmac = ''
* First look for total match
IF AT('?', codematch)=0
matchmac = field+"='"+codematch+"'"
ELSE
* Next for no match
cnt1 = 1
DO WHILE cnt1 <= len .AND. SUBSTR(codematch, cnt1, 1)='?'
cnt1 = cnt1 + 1
ENDDO
IF cnt1 <= len
* Now build matchmac for part match
cnt1 = 1
cnt2 = 1
DO WHILE cnt1 <= len
* Look for first non '?'
IF SUBSTR(codematch, cnt1, 1)='?'
cnt1 = cnt1 + 1
ELSE
scnt = cnt1
sstr = ''
DO WHILE cnt1 <= len .AND. SUBSTR(codematch, cnt1, 1)<>'?'
sstr = sstr + SUBSTR(codematch, cnt1, 1)
cnt1 = cnt1 + 1
ENDDO
IF cnt2 > 9
ext = STR(cnt2, 2, 0)
ELSE
ext = STR(cnt2, 1, 0)
ENDIF
work1 = 'SCNT'+ext
work2 = 'SLEN'+ext
work3 = 'SSTR'+ext
cnt2 = cnt2 + 1
&work1 = STR(scnt, 2, 0)
&work2 = STR(cnt1-scnt, 2, 0)
&work3 = sstr
ENDIF
ENDDO
* Now construct matchmac
cnt1 = 1
DO WHILE cnt1 < cnt2
IF LEN(matchmac) > 1
matchmac = matchmac + ' .AND. '
ENDIF
IF cnt1 > 9
ext = STR(cnt1, 2, 0)
ELSE
ext = STR(cnt1, 1, 0)
ENDIF
work1 = 'SCNT'+ext
work2 = 'SLEN'+ext
work3 = 'SSTR'+ext
matchmac = matchmac + 'SUBSTR('+field+','+&work1+','+;
&work2+')'+'='+"'"+&work3+"'"
cnt1 = cnt1 + 1
ENDDO
ENDIF
ENDIF
RELEASE cnt1, cnt2, work1, work2, work3, sstr, scnt, len
RETURN
* EOP